package com.huyucheng.todolist

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.fragment.app.FragmentTransaction
import androidx.lifecycle.ViewModelProviders

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        val fragment = supportFragmentManager.findFragmentByTag("TodoListFragment")
        val transaction: FragmentTransaction = supportFragmentManager.beginTransaction()

        if (fragment == null) {
            transaction.add(R.id.fragment_container, TodoListFragment(), "TodoListFragment")
        } else {
            transaction.show(fragment)
        }
        transaction.commit()
    }
}